<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<!--	<div class="form-group">-->
<!--	    <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>-->
<!--	    <div class="col-xs-12 col-sm-8">-->
<!--	        <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">-->
<!--	    </div>-->
<!--	</div>-->
<!--	-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Shop_category_id')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-shop_category_id" data-rule="required" -->
<!--			data-source="wanlshop/shopsort" -->
<!--			data-params='{"isTree":1}'-->
<!--			data-multiple="true"-->
<!--			class="form-control selectpage" -->
<!--			name="row[shop_category_id]" -->
<!--			type="text" -->
<!--			value="{$row.shop_category_id|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--	-->
<!--	<div class="form-group">-->
<!--	    <label class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>-->
<!--	    <div class="col-xs-12 col-sm-8">-->
<!--	        <input id="c-category_id" data-rule="required"-->
<!--			data-source="wanlshop/category/selectpage"-->
<!--			data-params='{"custom[type]":"goods","isTree":1}'-->
<!--			class="form-control selectpage"-->
<!--			name="row[category_id]"-->
<!--			type="text"-->
<!--			value="{$row.category_id|htmlentities}">-->
<!--	    </div>-->
<!--	</div>-->
<!--	-->
<!--    -->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <div class="input-group">-->
<!--                <input id="c-image" data-rule="required" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}">-->
<!--                <div class="input-group-addon no-border no-padding">-->
<!--                    <span><button type="button" id="plupload-image" class="btn btn-danger plupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>-->
<!--                    <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>-->
<!--                </div>-->
<!--                <span class="msg-box n-right" for="c-image"></span>-->
<!--            </div>-->
<!--            <ul class="row list-inline plupload-preview" id="p-image"></ul>-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <div class="input-group">-->
<!--                <input id="c-images" data-rule="required" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}">-->
<!--                <div class="input-group-addon no-border no-padding">-->
<!--                    <span><button type="button" id="plupload-images" class="btn btn-danger plupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>-->
<!--                    <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>-->
<!--                </div>-->
<!--                <span class="msg-box n-right" for="c-images"></span>-->
<!--            </div>-->
<!--            <ul class="row list-inline plupload-preview" id="p-images"></ul>-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-description" data-rule="required" class="form-control" name="row[description]" type="text" value="{$row.description|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Flag')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--                        -->
<!--            <select  id="c-flag" data-rule="required" class="form-control selectpicker" multiple="" name="row[flag][]">-->
<!--                {foreach name="flagList" item="vo"}-->
<!--                    <option value="{$key}" {in name="key" value="$row.flag"}selected{/in}>{$vo}</option>-->
<!--                {/foreach}-->
<!--            </select>-->

<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Stock')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--                        -->
<!--            <select  id="c-stock" data-rule="required" class="form-control selectpicker" name="row[stock]">-->
<!--                {foreach name="stockList" item="vo"}-->
<!--                    <option value="{$key}" {in name="key" value="$row.stock"}selected{/in}>{$vo}</option>-->
<!--                {/foreach}-->
<!--            </select>-->

<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Price')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-price" class="form-control" step="0.01" name="row[price]" type="number" value="{$row.price|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Freight_id')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-freight_id" data-rule="required" data-source="wanlshop/freight/index" class="form-control selectpage" name="row[freight_id]" type="text" value="{$row.freight_id|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Grounding')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-grounding" data-rule="required" class="form-control" name="row[grounding]" type="number" value="{$row.grounding|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Specs')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--                        -->
<!--            <select  id="c-specs" data-rule="required" class="form-control selectpicker" name="row[specs]">-->
<!--                {foreach name="specsList" item="vo"}-->
<!--                    <option value="{$key}" {in name="key" value="$row.specs"}selected{/in}>{$vo}</option>-->
<!--                {/foreach}-->
<!--            </select>-->

<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Distribution')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--                        -->
<!--            <select  id="c-distribution" data-rule="required" class="form-control selectpicker" name="row[distribution]">-->
<!--                {foreach name="distributionList" item="vo"}-->
<!--                    <option value="{$key}" {in name="key" value="$row.distribution"}selected{/in}>{$vo}</option>-->
<!--                {/foreach}-->
<!--            </select>-->

<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Activity')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--                        -->
<!--            <select  id="c-activity" data-rule="required" class="form-control selectpicker" name="row[activity]">-->
<!--                {foreach name="activityList" item="vo"}-->
<!--                    <option value="{$key}" {in name="key" value="$row.activity"}selected{/in}>{$vo}</option>-->
<!--                {/foreach}-->
<!--            </select>-->

<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Views')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-views" data-rule="required" class="form-control" name="row[views]" type="number" value="{$row.views|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Sales')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-sales" data-rule="required" class="form-control" name="row[sales]" type="number" value="{$row.sales|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Comment')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-comment" data-rule="required" class="form-control" name="row[comment]" type="number" value="{$row.comment|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Praise')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-praise" data-rule="required" class="form-control" name="row[praise]" type="number" value="{$row.praise|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Like')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-like" data-rule="required" class="form-control" name="row[like]" type="number" value="{$row.like|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            -->
<!--            <div class="radio">-->
<!--            {foreach name="statusList" item="vo"}-->
<!--            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> -->
<!--            {/foreach}-->
<!--            </div>-->

<!--        </div>-->
<!--    </div>-->
    {if condition="$row.status == 'examine'"}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('审核')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-status" data-rule="required" class="form-control" name="row[status]">
                <option value="normal" >通过</option>
                <option value="hidden" >不通过</option>
            </select>
        </div>
    </div>
    <div class="form-group" id="fail-reason-group" style="display: none;">
        <label class="control-label col-xs-12 col-sm-2">{:__('失败原因')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-fail-reason"  class="form-control" name="row[fail_reason]" type="text" value="{$row.fail_reason|htmlentities}">
        </div>
    </div>
    {/if}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('抽成比例')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-take-proportion" data-rule="required" class="form-control" name="row[take_proportion]" type="text" value="{$row.take_proportion|htmlentities}">
        </div>

    </div>

    <div class="form-group">
        <div style="padding: 0 150px;color: red">抽佣比例+分佣比例最大百分比不可超过30%，且设置比例时候注意该商家为平台设置的最大分账比例，填写比例相加超过商家设定的比例后将无法进行分账</div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('分佣比例')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-sharing-proportion" data-rule="required" class="form-control" name="row[sharing_proportion]" type="text" value="{$row.sharing_proportion|htmlentities}">
        </div>
    </div>
    <div class="form-group" id="points-type-all">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <label class="radio-inline">
                <input type="radio" name="row[points_type]" value="0" {if $row['points_type'] == '0'}checked{/if}> {:__('不抵扣')}
            </label>
            <label class="radio-inline">
                <input type="radio" name="row[points_type]" value="2" {if $row['points_type'] == '2'}checked{/if}> {:__('可抵扣金额百分比')}
            </label>
        </div>
    </div>

    <div class="form-group" id="points-deduction">
        <label  class="control-label col-xs-12 col-sm-2">{:__('积分最多抵扣百分比')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-points_deduction" class="form-control" data-rule="required"  name="row[points_deduction]" type="number" value="{$row.points_deduction|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <div style="padding: 0 150px;color: red">百分比是平台抽佣金额的百分比。例如 ：商品金额100元平台抽佣10元，那么百分比就是10元的可抵扣百分比</div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        var pointsTypeAll = document.getElementById('points-type-all');
        var pointsDeduction = document.getElementById('points-deduction');
        var pointsTypeRadios = pointsTypeAll.querySelectorAll('input[name="row[points_type]"]');
        pointsTypeRadios.forEach(function(radio) {
            radio.addEventListener('change', integral);
        });
        integral();
        function integral() {
            var pointsType = document.querySelector('input[name="row[points_type]"]:checked').value;
            hideGroup(pointsDeduction);
            if (pointsType == '2') {
                showGroup(pointsDeduction);
            }
        }
        $('#c-status').change(function(){
            if($(this).val() == 'examine') { // 当选择“不通过”
                $('#fail-reason-group').show(); // 显示“失败原因”输入框
            } else {
                $('#fail-reason-group').hide(); // 隐藏“失败原因”输入框
            }
        });

        // 页面加载时，检查是否需要显示“失败原因”输入框
        if($('#c-status').val() == '') {
            $('#fail-reason-group').show();
        }
        function hideGroup(group) {

            group.style.display = 'none';
            var inputs = group.querySelectorAll('input, select, textarea');
            inputs.forEach(function(input) {
                if (input.getAttribute('data-rule') === 'required') {
                    input.setAttribute('data-rule-original', 'required');
                    input.removeAttribute('data-rule');
                }
            });
        }

        function showGroup(group) {
            group.style.display = 'block';
            var inputs = group.querySelectorAll('input, select, textarea');
            inputs.forEach(function(input) {
                var originalRule = input.getAttribute('data-rule-original');
                if (originalRule) {
                    input.setAttribute('data-rule', originalRule);
                    input.removeAttribute('data-rule-original');
                }
            });
        }
    });

</script>
